(function (exports) {
    var $ = null;

    var TicketShopRecord = cc.Layer.extend({
        onEnter: function () {
            cc.Layer.prototype.onEnter.call(this);

            var data = {
                userid: gameData.uid + "",
                game_id: app.area + "",
            };
            network.sendProto(1045, data);
        },
        onExit: function () {
            cc.Layer.prototype.onExit.call(this);
        },
        ctor: function () {
            this._super();
            var that = this;

            var scene = loadNodeCCS(res.RecordLayer_json, this);
            $ = create$(this.getChildByName('Layer'));
            this._$ = $;

            // var size = $('bg').getContentSize();
            // var piaodai = getCreateRoomAni(7);
            // piaodai.setPosition(size.width/2, size.height - 50);
            // $('bg').addChild(piaodai);

            network.addListener(1046, function (data) {
                that._LogData = data.info;

                $('tip_no').setVisible(that._LogData.length <= 0);
                var tableViewSize = $('tableViewLayer').getSize();

                var tableviewLayer = $('tableViewLayer');
                var tableview = new cc.TableView(that, cc.size(tableViewSize.width, tableViewSize.height));
                tableview.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL);
                tableview.setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN);
                tableview.x = 0;
                tableview.y = 0;
                tableview.setDelegate(that);
                tableview.setBounceable(true);
                tableviewLayer.addChild(tableview);


                hideLoading();
            });

            TouchUtil.setOnclickListener($('btn_close'), function (node) {
                that.removeFromParent(true);
            });

        },
        tableCellTouched: function (table, cell) {
        },
        tableCellSizeForIndex: function (table, idx) {
            return cc.size(930, 52);
        },
        tableCellAtIndex: function (table, idx) {
            var cell = table.dequeueCell();
            if (cell == null) {
                cell = new cc.TableViewCell();
                // var row0 = ccs.load(res.Record_item_json, 'res/').node;
                var row0 = loadNodeCCSItem(res.Record_item_json);
                row0.setName('cellrow');
                cell.addChild(row0);
            }

            var node = cell.getChildByName('cellrow');
            $('lb_name', node).setString(this._LogData[idx].name);
            var time = timestamp2time(Math.floor(this._LogData[idx].time /1000));
            $('lb_time', node).setString(time);
            $('lb_content',node).setVisible(true);
            $('lb_content',node).setString('x'+this._LogData[idx].count);

            return cell;
        },
        numberOfCellsInTableView: function (table) {
            return this._LogData.length
        },
        scrollViewDidScroll: function (view) {
            var size = view.getContentOffset();

        },
        scrollViewDidZoom: function (view) {
        },
        _offsetFromIndex: function (view) {
        },

    });
    exports.TicketShopRecord = TicketShopRecord;

})(window);